package com.mr.utils;

import java.io.IOException;
import java.util.Map;

import org.codehaus.jackson.map.ObjectMapper;

/**
 * @author Alex
 */
public class JacksonUtils {

	private static final ObjectMapper MAPPER = new ObjectMapper();

	public static String convertToJsonStr(Object model) throws IOException {
		return MAPPER.writeValueAsString(model);
	}

	public static Map<String, Object> readFromStr(String content) throws IOException {
		return readFromStr(content, Map.class);
	}

	public static <T> T readFromStr(String content, Class<T> clazz) throws IOException {
		return MAPPER.readValue(content, clazz);
	}
}
